package cate.game.table;

import cate.common.table.EContextDefaultImpl;
import org.apache.commons.lang3.StringUtils;

import java.io.File;

public class GameTableContext extends EContextDefaultImpl {

    private String excelPath;
    private String excelMode;
    public GameTableContext(String excelPath, String excelMode) {
        this.excelPath = excelPath;
        this.excelMode = excelMode;
    }

    /** 填写在excelDir中的占位符 */
    public static final String MODE_PLACEHOLDER = "$MODE";

    @Override
    public File getFile(String fileName) {
        String dir;
        if(StringUtils.isNotBlank(excelMode)) {
            dir = excelPath.replace(MODE_PLACEHOLDER, excelMode);
        } else {
            dir = excelPath;
        }
        return new File(dir + fileName);
    }

}
